<%@ page import="com.entity.Blog" %>
<%@ page import="java.util.List" %>
<%@ page import="com.util.PageUtil" %><%--
  Created by IntelliJ IDEA.
  User: Elle
  Date: 2022/6/23
  Time: 9:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>显示所有博客</title>
</head>
<style>
  td,th{
    border: 1px solid ;
    width: 150px;
  }
</style>
<body>
<%

  PageUtil<Blog> pageUtil = (PageUtil) request.getAttribute("pageUtil");
  List<Blog> list = pageUtil.getShowList();
%>

博客总数：<%=list.size() %>
<table>
  <tr>
    <th>序号</th>
    <th>用户id</th>
    <th>内容</th>
    <th>操作</th>
  </tr>
  <%
    for(Blog tmp : list){
  %>
  <tr>
    <td><%=tmp.getId()%></td>
    <td><%=tmp.getUid()%></td>
    <td><%=tmp.getContent()%></td>
    <td>
      <a href="javascript:del(<%=tmp.getId()%>)">删除</a>
    </td>
  </tr>
  <%
    }
  %>
  <tr>
    <td colspan="4">
      <a href="BlogServlet?currentPage=1">首页</a> &nbsp;&nbsp;
      <a href="BlogServlet?currentPage=<%=pageUtil.getCurrentPage()<=1 ? 1 : pageUtil.getCurrentPage()-1 %>">上一页</a> &nbsp;&nbsp;
      <a href="BlogServlet?currentPage=<%=pageUtil.getCurrentPage()==pageUtil.getTotalPages() ? pageUtil.getTotalPages() : pageUtil.getCurrentPage()+1 %>">下一页</a> &nbsp;&nbsp;
      <a href="BlogServlet?currentPage=<%=pageUtil.getTotalPages() %>">尾页</a> &nbsp;&nbsp;
    </td>
  </tr>
</table>
<script src="js/jquery.js"></script>
<script>

  $(function () {
    $("tr:even").css("background-color","green");
  });

  function del(id) {
    var bool = confirm("您确定删除吗？");
    if(bool){
      //页面跳转
      location.href="BlogDelServlet?id="+id;
    }
  }
</script>
</body>
</html>
